package cn.broadsense.biz.service.impl;

import cn.broadsense.biz.domain.AppVersion;
import cn.broadsense.biz.mapper.AppVersionMapper;
import cn.broadsense.biz.service.AppVersionService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author huangjinshi
 * @description
 * @createDate 2023-09-25 10:42:58
 */
@Service
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements AppVersionService {


    @Override
    public AppVersion getLatest() {
        LambdaQueryWrapper<AppVersion> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppVersion::getStatus, 1);
        queryWrapper.orderByDesc(AppVersion::getReleaseTime);
        queryWrapper.last("limit 1");
        return this.baseMapper.selectOne(queryWrapper);
    }
}
